﻿<UserControl x:Class="U_UserHome.UserHomePage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:local="clr-namespace:U_UserHome"
             xmlns:Nav="clr-namespace:SSCCMembershipContent;assembly=SSCCMembershipContent" 
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    
    <UserControl.Resources>
        <Nav:NavigateCommand x:Key="Navigate"/>
    </UserControl.Resources>
        <ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto">   
        <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
            <RowDefinition Height="Auto"/>
         </Grid.RowDefinitions>

            <TextBlock TextWrapping="Wrap">Please note that you must update your details before you will be able to renew.</TextBlock>

            <ItemsControl x:Name="Members" Grid.Row="1">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition MaxWidth="350" />
                                <ColumnDefinition Width="100"/>
                                <ColumnDefinition Width="100"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="{Binding FullName}" VerticalAlignment="Center" Style="{StaticResource Heading}"/>
                            <Button Grid.Column="1" Command="{StaticResource Navigate}" Content="Update Details">
                                <Button.CommandParameter>
                                    <local:NavDest_PersonalDetails MemberID="{Binding ID}" />
                                </Button.CommandParameter>
                            </Button>
                            <CheckBox Grid.Column="2" VerticalAlignment="Center"  IsEnabled="{Binding UpdatedDetails}" IsChecked="{Binding RenewChecked, Mode=TwoWay}" IsThreeState="False">Renew</CheckBox>
                        </Grid>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="10"/><!--Indent-->
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <ItemsControl Grid.Column="1" IsEnabled="{Binding RenewChecked, Mode=OneWay, TargetNullValue=False}" ItemsSource="{Binding Racks}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="50"/>
                                                <ColumnDefinition MaxWidth="390"/>
                                                <!--Keep Renew Boxes in Line-->
                                                <ColumnDefinition />
                                            </Grid.ColumnDefinitions>
                                            <TextBlock HorizontalAlignment="Right" FontSize="16" Text="Rack "/>
                                            <TextBlock Grid.Column="1" Text="{Binding Name}" FontSize="16"/>
                                            <CheckBox Grid.Column="2" IsChecked="{Binding RenewChecked, Mode=TwoWay}">Renew</CheckBox>
                                        </Grid>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </Grid>
                    </StackPanel>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
       

        <Button Grid.Row="2" Click="Renew" x:Name="btnRenew" IsEnabled="False">Renew Now</Button>
    </Grid>  
    </ScrollViewer>
</UserControl>
